package cn.com.ry.framework.mongodb.sync.entity;

import java.io.Serializable;

public class Page implements Serializable {

    public String getCollectionName() {
        return collectionName;
    }

    public void setCollectionName(String collectionName) {
        this.collectionName = collectionName;
    }

    //mongo集合名称
    private String collectionName;
    //每页大小
    private int pageSize;
    //记录总数
    private int totalRecord;
    //当前页数
    private int currentPage;
    //总页数
    private int totalPage;
    //queue 索引大小
    private int queueSize;
    //断点续传或，记录是否已经执行
    private boolean runStatus;

    //记录collection 最大_id
    private String maxObjectId;

    public Page() {
        this.pageSize = 10;
        this.totalRecord = 0;
        this.currentPage = 1;
    }

    public Page(int currentPage, int pageSize) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
    }

    public Page(int currentPage, int totalRecord, int pageSize) {
        this.pageSize = 10;

        this.totalRecord = 0;

        this.currentPage = 1;

        this.currentPage = currentPage;
        this.totalRecord = totalRecord;
        this.pageSize = pageSize;
    }

    public int getRecordIndex() {
        if (this.currentPage > 0)
            return ((this.currentPage - 1) * this.pageSize);

        return 0;
    }

    public int getRecordStart() {
        if (this.currentPage > 0)
            return ((this.currentPage - 1) * this.pageSize + 1);

        return 0;
    }

    public int getRecordEnd() {
        if (this.currentPage > 0)
            return (this.currentPage * this.pageSize);

        return 0;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalRecord() {
        return this.totalRecord;
    }

    public void setTotalRecord(int totalRecord) {
        this.totalRecord = totalRecord;
    }

    public int getCurrentPage() {
        return this.currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotalPage() {
        this.totalPage = (int) Math.floor(this.totalRecord * 1D / this.pageSize);
        if (this.totalRecord % this.pageSize != 0)
            this.totalPage = (this.totalPage + 1);

        if (this.totalPage == 0)
            return 1;

        return this.totalPage;
    }

    public int getQueueSize() {
        return queueSize;
    }

    public void setQueueSize(int queueSize) {
        this.queueSize = queueSize;
    }

    public boolean isRunStatus() {
        return runStatus;
    }

    public void setRunStatus(boolean runStatus) {
        this.runStatus = runStatus;
    }

    public String getMaxObjectId() {
        return maxObjectId;
    }

    public void setMaxObjectId(String maxObjectId) {
        this.maxObjectId = maxObjectId;
    }
}
